/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package benarytree;

/**
 *
 * @author Дмитрий
 */

public class TreeNode {
    private String value;//data
    private int id;// node id
    private int leftChild = -1;// index that show left child 
    private int rightChild = -1;// index that show right child
    private int level = -1; // level: for root is a 0, for root's children is 1
                            // and so on...     

    public TreeNode(int id, String data) {
        this.id = id;
        this.value = data;
    }
    
    public TreeNode(int id, String data, int leftChild, int rightChild) {
        this.id = id;
        this.value = data;
        this.leftChild = leftChild;
        this.rightChild = rightChild;
    }

    public int getLeftChild() {
        return leftChild;
    }

    public int getRightChild() {
        return rightChild;
    }

    public String getData() {
        return value;
    }

    public void setLeftChild(int leftChild) {
        this.leftChild = leftChild;
    }

    public void setRightChild(int rightChild) {
        this.rightChild = rightChild;
    }

    public int getId() {
        return id;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    public int getLevel() {
        return level;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
	}
		
        if (obj == null) {
		return false;
	}
        
	if (getClass() != obj.getClass()) {
		return false;
	}
        
        TreeNode treeNode = (TreeNode)obj;
        
        return id == treeNode.id;   
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 53 * hash + this.id;
        return hash;
    }
}
